package checkers3d.logic;

import checkers3d.presentation.IRenderResource;
import java.awt.Point;

/**
 *
 * @author Ruben Acuna
 * @author Leila Malekian
 */
public class BoardObjectKingify implements IBoardObject
{
    private Player owner;

    //for IDrawable
    Point drawPosition;
    IRenderResource resource;

    public BoardObjectKingify(Player player)
    {
        setOwner(player);
        setDrawPosition(new Point());
        setRenderResource(null);
    }

    //START - STUFF FROM IDRAWABLE
    public Point getDrawPosition()
    {
        return drawPosition;
    }

    public void setDrawPosition(Point position)
    {
        drawPosition = position;
    }

    public IRenderResource getRenderResource()
    {
        return resource;
    }

    public void setRenderResource(IRenderResource resource)
    {
        this.resource = resource;
    }
    
    //END - STUFF FROM IDRAWABLE
    
    public int getSetupCount(int boardSizeX, int boardSizeY, int boardSizeZ)
    {
        int setupCount = boardSizeX * boardSizeZ;
        
        return setupCount;
    }

    public void setOwner (Player player)
    {
        owner = player;
    }

    public Player getOwner()
    {
        return owner;
    }

    public boolean isBlocking() //returns true when a piece is occupying a square
    {
        return false;
    }

    public boolean isVisibleTo(Object player)//everything is visible at this point in the build
    {
        return true;
    }

    public boolean isValidSetupPosition(PlayingSurface3D playingSurface3D, Point3D location)
    {
        boolean valid = false;
        
            if(location.y == playingSurface3D.getSizeY() - 1)
                valid = true;

        return valid;
    }

    public BoardObjectTouchEffect onTouch(IBoardObject other)
    {
        if(other.getOwner() == this.getOwner() && (other instanceof BoardObjectChecker))
            return BoardObjectTouchEffect.KINGIFY;
        else
            return BoardObjectTouchEffect.NOTHING;
    }

    /**
     * Returns a new instance of this object type with all local variables the
     * same.
     *
     * @return A new instance of this object.
     * @see IBoardObject
     */    
    @Override
    public IBoardObject clone()
    {
        return new BoardObjectKingify(getOwner());
    }

    public String getDataAsString(){
        return ("Kingify\t" + owner.getDataAsString());
    }

    @Override
    public String toString(){
        return (getClass().getSimpleName() + " - owner:" + getOwner().getName());
    }
}
